package yannan.voiplock4ble.bean.ble;

import yannan.voiplock4ble.utils.ByteUtils;

/**
 * 说明：发起原生命令的响应
 * 作者：mainTel
 * 时间：2017/2/10 14:21
 * 备注：
 */

public class RemoteUpgradeACK extends BaseBleResponse {

/*
//Remote_Upgrade_ACK_ID
//远程升级的响应命令
typedef struct{
	AppCommandHead_T head;
	uint8_t		cmd; //
	uint8_t   reserve;	//对齐保留
	uint16_t	token;//
	uint8_t 	reason;						//升级命令响应结果 0:可以升级 ，30:版本不匹配  状态为0时下面的字段有效
	uint16_t	pkt_size;					//可接受的每包尺寸
	uint16_t	start_sn;			//续传起始包
}UserUpdateAck_t;
 */

    public boolean reason;
    public int pkt_size;
    public int start_sn;

    public RemoteUpgradeACK(byte[] response) {
        super(response);
        reason = (content[0] & 0xff) == 0;
        pkt_size = Integer.parseInt(ByteUtils.bytesToHexString(new byte[]{content[2], content[1]}), 16);
        start_sn = Integer.parseInt(ByteUtils.bytesToHexString(new byte[]{content[4], content[3]}), 16);
    }
}
